/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfbmonitor.view.database;


import javax.swing.JPanel;

import org.jfbmonitor.language.Language;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;


/**
 *
 * @author Douglas
 */
public class DataBaseIOChart extends JPanel{
	
	private static XYSeries seriesOldestTransaction = new XYSeries(Language.getInstance().getProperties("TABLE.OLDESTTRANSACTION"));
	private static XYSeries seriesOldestActive = new XYSeries(Language.getInstance().getProperties("TABLE.OLDESTACTIVE"));
	private static XYSeries seriesNextTransaction = new XYSeries(Language.getInstance().getProperties("TABLE.NEXTTRANSACTION"));
	
	
public static ChartPanel getGrafico(){
		
		JFreeChart chart = ChartFactory.createTimeSeriesChart
		                     (Language.getInstance().getProperties("CHARTDATABASE.TITLE"), 
		                    		 Language.getInstance().getProperties("CHARTDATABASE.X"),        
		                    		 Language.getInstance().getProperties("CHARTDATABASE.Y"),        
		                      createDataset(),
		                      true,
		                      true,
		                      false);
		
        ChartPanel chartPanel = new ChartPanel(chart, false);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
        chartPanel.setMouseZoomable(true, false);
	
		return chartPanel;
	}
	
	
	  private static XYDataset createDataset() {		  
		  
		  XYSeriesCollection dataset = new XYSeriesCollection();
		  dataset.addSeries(seriesOldestTransaction);
		  dataset.addSeries(seriesOldestActive);
		  dataset.addSeries(seriesNextTransaction);
	      return dataset;

	    }	
	  
	 public void addSeriesOldestTransaction(int period, int value){		 
		 seriesOldestTransaction.add(period, value);		 
	 }	 
	 
	 public void addSeriesOldestActive(int period, int value){		 
		 seriesOldestActive.add(period, value);
	 }
	 
	 public void addSeriesNextTransaction(int period, int value){	 
		 seriesNextTransaction.add(period, value);		 
	 }
	 
	
}
